Represents a 4x4 float matrix. More...
Public Member Functions | |
Matrix () | |
Matrix (float x0, float y0, float z0, float w0, float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2, float x3, float y3, float z3, float w3) | |
Matrix (const Matrix &other) | |
Matrix (const DirectX::XMMATRIX &values) | |
~Matrix () | |
DirectX::XMMATRIX | getValues () const |
Matrix | getInverse () const |
Matrix | getTranspose () const |
Vector | getPositionComponent () const |
Quaternion | getOrientationComponent () const |
Vector | getScaleComponent () const |
void | getDecomposed (Vector &position, Quaternion &orientation, Vector &scale) |
Vector | getFirstRow () const |
Vector | getSecondRow () const |
Vector | getThirdRow () const |
Vector | getFourthRow () const |
void | setToRotationFromQuaternion (const Quaternion &origin) |
void | setToViewMatrixDirection (const Vector &position, const Vector &direction, const Vector &upDirection) |
void | setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) |
void | setToOrthographicMatrix (float fov, float camSpaceWidth, float camSpaceHeight, float nearVal, float farVal) |
void | setToTransformation (const Vector &position, const Quaternion &orientation, const Vector &scale) |
void | inverse () |
void | transpose () |
float | get (unsigned int row, unsigned int col) const |
void | set (float val, unsigned int row, unsigned int col) |
float | getDeterminantMat3 () const |
float | getDeterminantMat4 () const |
float | getTraceMat3 () const |
float | getTraceMat4 () const |
void | fromString (const std::string_view &str) |
Matrix & | operator= (const Matrix &other) |
bool | operator== (const Matrix &other) |
bool | operator!= (const Matrix &other) |
Matrix | operator+ (const Matrix &other) const |
void | operator+= (const Matrix &other) |
Matrix | operator- (const Matrix &other) const |
void | operator-= (const Matrix &other) |
Matrix | operator* (const Matrix &other) const |
Vector | operator* (const Vector &toApply) const |
Matrix | operator* (float scalar) const |
void | operator*= (const Matrix &other) |
void | operator*= (float scalar) |
Matrix | operator/ (float scalar) const |
void | operator/= (float scalar) |
Represents a 4x4 float matrix.
nkMaths::Matrix::Matrix | ( | ) |
Default constructor.
nkMaths::Matrix::Matrix | ( | float | x0, |
float | y0, | ||
float | z0, | ||
float | w0, | ||
float | x1, | ||
float | y1, | ||
float | z1, | ||
float | w1, | ||
float | x2, | ||
float | y2, | ||
float | z2, | ||
float | w2, | ||
float | x3, | ||
float | y3, | ||
float | z3, | ||
float | w3 | ||
) |
Filling constructor.
x0 | The x for line 0. |
y0 | The y for line 0. |
z0 | The z for line 0. |
w0 | The w for line 0. |
x1 | The x for line 1. |
y1 | The y for line 1. |
z1 | The z for line 1. |
w1 | The w for line 1. |
x2 | The x for line 2. |
y2 | The y for line 2. |
z2 | The z for line 2. |
w2 | The w for line 2. |
x3 | The x for line 3. |
y3 | The y for line 3. |
z3 | The z for line 3. |
w3 | The w for line 3. |
nkMaths::Matrix::Matrix | ( | const Matrix & | other | ) |
Copy constructor.
other | The matrix to copy from. |
nkMaths::Matrix::Matrix | ( | const DirectX::XMMATRIX & | values | ) |
Filling constructor.
values | The XM values. |
nkMaths::Matrix::~Matrix | ( | ) |
Destructor.
DirectX::XMMATRIX nkMaths::Matrix::getValues | ( | ) | const |
Matrix nkMaths::Matrix::getInverse | ( | ) | const |
Matrix nkMaths::Matrix::getTranspose | ( | ) | const |
Vector nkMaths::Matrix::getPositionComponent | ( | ) | const |
Quaternion nkMaths::Matrix::getOrientationComponent | ( | ) | const |
Vector nkMaths::Matrix::getScaleComponent | ( | ) | const |
void nkMaths::Matrix::getDecomposed | ( | Vector & | position, |
Quaternion & | orientation, | ||
Vector & | scale | ||
) |
Decomposes the matrix into a set of translation, orientation, and scale, if we consider the matrix as a 4x4 transformation matrix.
position | The position, translation component to fill. |
orientation | The orientation component to fill. |
scale | The scale component to fill. |
Vector nkMaths::Matrix::getFirstRow | ( | ) | const |
Vector nkMaths::Matrix::getSecondRow | ( | ) | const |
Vector nkMaths::Matrix::getThirdRow | ( | ) | const |
Vector nkMaths::Matrix::getFourthRow | ( | ) | const |
void nkMaths::Matrix::setToRotationFromQuaternion | ( | const Quaternion & | origin | ) |
Sets the rotation component in the matrix from a quaternion.
origin | The quaternion to use as orientation. |
void nkMaths::Matrix::setToViewMatrixDirection | ( | const Vector & | position, |
const Vector & | direction, | ||
const Vector & | upDirection | ||
) |
Sets the matrix as a view matrix.
position | The eye position. |
direction | The eye front direction. |
upDirection | The eye up direction. |
void nkMaths::Matrix::setToPerspectiveMatrix | ( | float | fov, |
float | aspect, | ||
float | nearVal, | ||
float | farVal | ||
) |
Sets the matrix as a perspective matrix.
fov | The field of view, vertical, in radians. |
aspect | The aspect ratio. |
nearVal | The near plane distance. |
farVal | The far plane distance. |
void nkMaths::Matrix::setToOrthographicMatrix | ( | float | fov, |
float | camSpaceWidth, | ||
float | camSpaceHeight, | ||
float | nearVal, | ||
float | farVal | ||
) |
Sets the matrix as an orthographic matrix.
fov | The field of view, vertical, in radians. |
camSpaceWidth | The width of the matrix, in eye space distance. |
camSpaceHeight | The height of the matrix, in eye space distance. |
nearVal | The near plane distance. |
farVal | The far plane distance. |
void nkMaths::Matrix::setToTransformation | ( | const Vector & | position, |
const Quaternion & | orientation, | ||
const Vector & | scale | ||
) |
Sets the matrix as a full transformation matrix.
position | The position, translation component to bake. |
orientation | The orientation component to bake. |
scale | The scale component to bake. |
void nkMaths::Matrix::inverse | ( | ) |
Inverses the matrix.
void nkMaths::Matrix::transpose | ( | ) |
Transposes the matrix.
float nkMaths::Matrix::get | ( | unsigned int | row, |
unsigned int | col | ||
) | const |
row | The row of the member to retrieve. |
col | The col of the member to retrieve. |
void nkMaths::Matrix::set | ( | float | val, |
unsigned int | row, | ||
unsigned int | col | ||
) |
val | The value to set in the matrix. |
row | The row to override. |
col | The col to override. |
float nkMaths::Matrix::getDeterminantMat3 | ( | ) | const |
float nkMaths::Matrix::getDeterminantMat4 | ( | ) | const |
float nkMaths::Matrix::getTraceMat3 | ( | ) | const |
float nkMaths::Matrix::getTraceMat4 | ( | ) | const |
void nkMaths::Matrix::fromString | ( | const std::string_view & | str | ) |
Interprets a string to set the components of the matrix. Format is x0,y0,z0,w0,...
str | The string to parse. |
Assignment operator.
other | The matrix to assign. |
bool nkMaths::Matrix::operator== | ( | const Matrix & | other | ) |
Equality operator.
other | The matrix to check against. |
bool nkMaths::Matrix::operator!= | ( | const Matrix & | other | ) |
Inequality operator.
other | The matrix to check against. |
Addition operator.
other | The matrix to operate with. |
void nkMaths::Matrix::operator+= | ( | const Matrix & | other | ) |
Addition and assignment operator.
other | The matrix to operate with. |
Subtraction operator.
other | The matrix to operate with. |
void nkMaths::Matrix::operator-= | ( | const Matrix & | other | ) |
Subtraction and assignment operator.
other | The matrix to operate with. |
Transformation operator.
other | The matrix to operate with. |
Transformation operator.
toApply | The matrix to operate with. |
Matrix nkMaths::Matrix::operator* | ( | float | scalar | ) | const |
Multiplication operator.
scalar | The scalar to operate with. |
void nkMaths::Matrix::operator*= | ( | const Matrix & | other | ) |
Transformation and assignment operator.
other | The matrix to operate with. |
void nkMaths::Matrix::operator*= | ( | float | scalar | ) |
Multiplication and assignment operator.
scalar | The scalar to operate with. |
Matrix nkMaths::Matrix::operator/ | ( | float | scalar | ) | const |
Division operator.
scalar | The scalar to operate with. |
void nkMaths::Matrix::operator/= | ( | float | scalar | ) |
Addition and assignment operator.
scalar | The scalar to operate with. |